package medium

func sumSubarrayMins(arr []int) int {
	ans := 0

	for len(arr) > 0 {
		stack := arr
		i := len(stack)

		minNumber := stack[i]
		for _, v := range stack {
			if minNumber > v {
				minNumber = v
			}
		}

		arr = arr[:len(arr)-1]
		ans += minNumber
	}

	return ans
}
